<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>06_emit</title>
</head>

<body>
    <div id="app">
        <cpn @send-hobies="getHobies"></cpn>
        <h3>您的爱好是: {{fatherHobies}}</h3>
    </div>
</body>

<template id="aa">
    <div>
        <input type="checkbox" v-model="hobies" value="篮球">篮球
        <input type="checkbox" v-model="hobies" value="足球">足球
        <input type="checkbox" v-model="hobies" value="拍球">拍球
        <input type="checkbox" v-model="hobies" value="桌球">桌球
    </div>
</template>
<script src="../vue.js"></script>
<script>
    new Vue({
        el: '#app',
        components: {
            'cpn':{
                template: '#aa',
                methods: {
                    sonClick(){
                        this.$emit('ss')
                    }
                },
                data(){
                    return {
                        hobies: []
                    }
                },
                watch: {
                    hobies(value){
                        this.$emit('send-hobies',value)
                    }
                }
            }
        },
        data: {
            fatherHobies: ['乒乓求']
        },
        methods: {
            getHobies(value){
               this.fatherHobies = value
            }
        }
    })
</script>
</html>